﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace Blank.Data.Models
{
    [DataContract]
    [KnownType(typeof(ParameterDirection))]
    [KnownType(typeof(System.Data.DbType))]
    public class DBParameter
    {
        [DefaultValue(typeof(ParameterDirection), "Input")]
        [DataMember]
        public ParameterDirection Direction { get; set; }
        [DataMember]
        public string ParameterName { get; set; }
        [DataMember]
        public object Value { get; set; }
        [DataMember]
        public System.Data.DbType DbType { get; set; }
        [DataMember]
        public int Size { get; set; }
        public void CreateDBParameter(string parameterName, object value, System.Data.DbType dbType = System.Data.DbType.String)
        {
            CreateDBParameter(parameterName, value, dbType, ParameterDirection.Input, int.MaxValue);
        }
        public void CreateOutPutParameter(string parameterName, System.Data.DbType dbType = System.Data.DbType.String)
        {
            CreateDBParameter(parameterName, null, dbType, ParameterDirection.Output, int.MaxValue);
        }
        public void CreateDBParameter(string parameterName, object value, System.Data.DbType dbType, ParameterDirection direction, int size)
        {
            this.ParameterName = parameterName;
            this.Value = value;
            this.DbType = dbType;
            this.Direction = direction;
            this.Size = size;
        }

    }
}
